package univ.uchiha.esiag.gon.domaine;

import univ.uchiha.esiag.gon.publisher.Publisher;
import univ.uchiha.esiag.gon.subscriber.impl.SubscriberImpl;

public class SPManager {
	private SubscriberImpl subscriber;
	private Publisher publisher;
	private int counter;
	private int maxUse;
	public SPManager(SubscriberImpl subscriber, Publisher publisher, int maxUse) {
		this.subscriber = subscriber;
		this.publisher = publisher;
		this.counter = 0;
		this.maxUse = maxUse;
	}
	public SubscriberImpl getSubscriber() {
		return subscriber;
	}
	public Publisher getPublisher() {
		return publisher;
	}
	public boolean use(){
		if(counter == maxUse)
			return false;
		this.counter++;
		return true;
	}
	public void unuse(){
		this.counter--;
	}
	public int getCounter() {
		return counter;
	}
}
